package com.filyar.htyd.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaIgnore;
import com.filyar.htyd.common.ExceptionEnum;
import com.filyar.htyd.common.Result;
import com.filyar.htyd.exception.ServiceException;
import com.filyar.htyd.utils.RegionUtil;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/test")
@RestController
public class TestController {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @SaIgnore
    @GetMapping("/2")
    public void test2() {
        throw new ServiceException(ExceptionEnum.TEST);
    }

    @SaIgnore
    @GetMapping("/3")
    public void test3() {
        throw new RuntimeException("系统异常抛出内容");
    }
    @SaCheckLogin(type = "mobile")
    @GetMapping("/4/{ip}")
    public Result test4(@PathVariable String ip) {
        String cityInfo = RegionUtil.getCityInfo(ip);
        return Result.success(cityInfo);
    }
}